<script type="text/javascript">
$(document).ready(function(){

    $("#addCategory").click(function(event){
        event.preventDefault();
        loadView("/category/activeaddcategory", $("#boxCreateCategory"), function(){
        	$('#formcategory').attr('action','/category/addusercategory');
            prepareInputsForHints();
        });
    });

    $('#feedcategory').bind("updateCategories", function(event) {
        loadUserCategory($('#feedcategory'), '/category/loadusercategories', null);
    });

    var feedOptions = {
        dataType: "json", 
        beforeSubmit: function(data) {
            $('#addfeedmsg').html('<img alt="<?=$this->translate('feedupgradeMsg') ?>" src="/img/ajax-loader.gif"/><?=$this->translate('feedloadinfoMsg') ?>');
        },   
        success: function(data) { 
             if (data.error == false) { 
                 jQuery.facebox("<?= $this->translate('okMsg') ?>");
                 $("#feedTreeContent").trigger("updateFeedTree");
                 $("#formfeed").hide('blind', function(){
                     $("#formfeed").remove();
                 });
             } else {
                 jQuery.facebox(parseJsonValidation(data.messages));
                 $('#addfeedmsg').empty();
             } 
         },
        error:   function (xhr, ajaxOptions, thrownError) {
        	 $('#addfeedmsg').empty();
             jQuery.facebox("<?= $this->translate('ajaxError') ?>");
        }
     };

     $('#formfeed').ajaxForm(feedOptions);

});
</script>

<form id="<?= $this->escape($this->formAddfeed->getAttrib("id"))?>"
      class="<?= $this->escape($this->formAddfeed->getAttrib("class"))?>" 
      action="<?= $this->escape($this->formAddfeed->getAction())?>" 
      method="<?= $this->escape($this->formAddfeed->getMethod())?>">
      <ul>
          <li>
            <span id="addfeedmsg"></span>
          </li>   
          <li class="element-group">
            <?= $this->formAddfeed->url ?>
            <span class="hint"><?= $this->translate('insertURL')?></span>    
          </li>
          <li class="element-group">
            <div class="createCategory">
                <?= $this->formAddfeed->category ?>
                <div class="element-group-selectblock">
                    <p id="addCategory" class="addbox">+</p>
                </div>    
            </div>   
          </li>
          <li class="element-group-addCategory">
            <div id="boxCreateCategory" class="boxCreateCategory">
                <!-- visualizzazione del box di creazione categoria tramite ajax -->
            </div>
          </li>
          <li class="element-group">
            <?= $this->formAddfeed->submit ?>    
          </li>
            <?= $this->formAddfeed->param ?>
      </ul>
</form>  
